<?php
/**
 * 小程序API
 * Created by Forever.
 * User: Forever
 * Date: 2018/8/27 0027
 * Time: 上午 9:39
 */
namespace app\api\controller;
use think\Controller;
use think\Request;
use \think\Db;
use think\Validate;
class Mini extends Base
{

    public function getToken(){
        $data =$this->data;
        $result = model('Mini')->getMiniToken();
        return $result;
    }

    /*
     * 获取SessionKey
     */
	public function getSessionKey(){
        $data = input('post.');
        $check = $this->validate($data,'Mini.code');
        if($check !==true){
           return api_return($check);
        }
        $result = model('Mini')->getSessionKey($data);
        if($result != 10001 ){
            return api_return($result);
        }else{
            return api_return('10002',$options);
        }

    }

    /*
     * 获取用户信息
     *
     */
    public function getUserInfo(){
        $data = input('post.');
        $check = $this->validate($data,'Mini.user');
        if($check !==true){
            return api_return($check);
        }
        $options = model('Mini')->getUserInfo($data);
        if($options !== false ){
            return api_return('10002',$options);
        }else{
            return api_return($options);
        }
    }


    public function getCode(){
        $path = "pages/index/index";
        $code = model('Mini')->getQrCode($path);
        return $code;

    }



}
